<template>
  <el-drawer title="一知对接token" :visible.sync="$attrs.visableIf" @close="handleCloseDialog" :close-on-click-modal="false" :close-on-press-escape="false" append-to-body size="1000px">
    <div class="drawer-body">
      <div class="formBig">
        <div class="item-li row-li">对接Token换取：<span style="cursor: pointer; color: #2d8cf0">查看如何对接</span></div>
        <div class="item-li">账号ID：<div class="content">5424982</div></div>
        <div class="item-li">所属公司：<div class="content">安徽志新科技有限公司</div></div>
      </div>
      <el-button type="primary" plain style="margin-bottom: 10px" size="small" @click="getChooseGroup"><i class="el-icon-plus"></i>生成分组token</el-button>
      <el-table
        :data="tableDataList"
        ref="companylabelList"
      >
        <el-table-column
          :label="item.label"
          align="center"
          v-for="(item, index) in tableColumns"
          :key="index"
          :prop="item.key"
          :min-width="item.minWidth ? item.minWidth : ``"
          :fixed="item.fixed ? item.fixed : false"
          :show-overflow-tooltip="true"
        >
          <!--用于表格自定义-->
          <template slot-scope="scope">
            <div v-if="item.key=='name'">
            </div>
            <div class="label-list" v-else-if="item.key=='label2'">
              <span>未入VIP群</span>
              <span>持续7天未发言</span>
              <span>1000</span>
              <div class="btn-r" @click="getShowTags(1)">设置</div>
            </div>
            <div class="label-list" v-else-if="item.key=='label3'">
              <span>未入VIP群</span>
              <span>持续7天未发言</span>
              <span>1000</span>
              <div class="btn-r" @click="getShowTags(2)">设置</div>
            </div>

            <div v-else style="text-align: center">{{ scope.row[item.key] }}</div>
          </template>
        </el-table-column>
        <el-table-column
          fixed="right"
          label="操作"
          width="100">
          <template slot-scope="scope">
            <el-button  type="text" size="small">复制</el-button>
          </template>
        </el-table-column>
      </el-table>
      <pagination
        v-show="total>0"
        :total="total"
        :page.sync="queryParams.pageNum"
        :limit.sync="queryParams.pageSize"
        @pagination="getList"
      />
    </div>
    <selectAllTags v-if="showSelectAllTags" :visableIf.sync="showSelectAllTags" :dataList="dataAllList" :chooseValue="chooseValue" @upDataList="upDataList"></selectAllTags>
    <chooseGroup v-if="showChooseGroup" :visableIf.sync="showChooseGroup"></chooseGroup>
  </el-drawer>

</template>

<script>
// import {reqGetOriginalDetailsById, reqAddOriginality, reqEditOriginality} from '@/api/originalityMgt/index';

import {listUser} from "@/api/system/user";
import selectAllTags from './selectAllTags';
import chooseGroup from './chooseGroup';
export default {
  name: "yizhiExport",
  props:{
    drawerPage:String,
    default:()=>{
      return 'yijie'
    }
  },
  components: {
    selectAllTags,
    chooseGroup,
  },
  data() {
    return {
      showSelectAllTags:false,
      showChooseGroup:false,
      tableHeight: 600,
      tableColumns: [
        {key: 'group', label: `分组`, visible: true, minWidth: 100, fixed: true},
        {key: 'Token', label: `Token`, visible: true, minWidth: 150, fixed: false},
        {key: 'label2', label: `自动打标签`, visible: true, minWidth: 150, fixed: false},
        {key: 'label3', label: `自动打智能标签`, visible: true, minWidth: 150, fixed: false},
      ],
      tableDataList: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        id: null,//用户id
        userName1: null,

      },
      total: 8, // 表格的总条数
      dataAllList:[],
      dataList: [
        {
          field: "gasUser",
          label: "社群行为",
          showChild:true,
          child: [
            {
              field: "userId",
              label: "未入常规群",
              dictKey: null,
              dateFormat: null
            },
            {
              field: "userName",
              label: "已入常规群",
              dictKey: null,
              dateFormat: null
            }
          ]
        },
        {
          field: "gasUserInfo",
          label: "私聊活跃度",
          showChild:true,
          child: [
            {
              field: "certificateType",
              label: "新好友1小时未发言",
              dictKey: "certificate_type",
              dateFormat: null
            },
            {
              field: "certificateNo",
              label: "持续3天未发言",
              dictKey: null,
              dateFormat: null
            }
          ]
        },

      ],
      dataList2: [
        {
          field: "week",
          label: "生命周期",
          showChild:true,
          child: [
            {
              field: "we1",
              label: "孕4周",
              dictKey: null,
              dateFormat: null
            },
            {
              field: "we2",
              label: "孕8周",
              dictKey: null,
              dateFormat: null
            },
          ]
        },
      ],
      chooseValue:['gasUser'],//选中的数据
      rules: {
        param: [
          {required: true, message: '请添加素材', trigger: 'blur'},
        ],
        type_name: [
          {required: true, message: '请输入素材分类', trigger: 'blur'},
        ],

      },
    }
  },
  created() {

    for (let i=0;i<2; i++){
      let obj={
        group:'分组'+i,
        Token:'2945454545535hhh',
        label2:'自动打标签',
        label3:'自动打智能标签',
      }
      this.tableDataList.push(obj);
    }

  },
  methods: {
    getChooseGroup(){
      this.showChooseGroup=true;
    },
    getShowTags(type){
      if(type==1){
       this.dataAllList=this.dataList;
      }else{
        this.dataAllList=this.dataList2;
      }
      this.showSelectAllTags=true;
    },
    upDataList(code,list){
      //获取到查询的参数，更新数据
      console.log('获取值然后更新接口',code,list);
      //写接口的逻辑
    },
    /** 查询用户列表 */
    getList() {
      this.loading = true;
      listUser(this.addDateRange(this.queryParams, this.dateRange)).then(response => {
          this.tableDataList = response.rows;
          this.total = response.total;
          this.loading = false;
        }
      );
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.dateRange = [];
      this.resetForm("queryForm");
      this.queryParams.deptId = undefined;
      this.handleQuery();
    },
    handleCloseDialog() {
      this.$emit('update:visableIf', false);
      this.$emit("handleCloseFilter"); //关闭弹窗;
    },
  }
}
</script>

<style scoped lang="scss">
.el-form {
  ::v-deep .el-form-item {
    .el-form-item__label {

    }

    .el-form-item__content {
      .el-input__inner {
        border-radius: 0px;
        height: 32px;
        border-radius: 0px 0px 0px 0px;
        border: 1px solid #BEBEBE;
        line-height: 32px;
      }
    }
  }

  .imagesList {
    display: flex;
    flex-wrap: wrap;

    li {
      list-style: none;
      height: 120px;
      width: 150px;
      margin-right: 10px;
      position: relative;
      margin-bottom: 10px;
      border-radius: 5px;
      border: 1px solid #eee;

      &:hover {
        .top-icon {
          display: flex;
        }
      }

      img {
        width: 100%;
        height: 100%;
        object-fit: cover;
      }

      .top-icon {
        position: absolute;
        left: 0px;
        width: 100%;
        height: 100%;
        top: 0px;
        // display: flex;
        align-items: center;
        justify-content: center;
        z-index: 1;
        display: none;

        i {
          margin: 0px 10px;
          color: #fff;
          font-size: 20px;
          cursor: pointer;

        }

        &:after {
          position: absolute;
          width: 100%;
          height: 100%;
          background: #000;
          opacity: 0.7;
          left: 0px;
          content: '';
          z-index: -1;
        }
      }
    }
  }
}

::v-deep .el-drawer {
  .drawer-body {
    overflow-y: auto;
    padding: 20px 20px;
  }

  .drawer-footer {
    position: absolute;
    width: 100%;
    height: 50px;
    background: #eee;
    bottom: 0px;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    padding: 0px 20px;
    box-sizing: border-box;

    .el-button--medium {
      padding: 5px 20px;
      height: 32px;
      display: flex;
      align-items: center;
      justify-content: center;
    }
  }
}

.label-list {
  display: flex;
  flex-wrap: wrap;
  label {
    font-size: 14px;
    line-height: 1.5715;
    word-wrap: break-word;
    font-weight: 400;
  }

  i {
    cursor: pointer;

  }

  span {
    margin: 4px 4px 4px 0;
    font-size: 12px;
    height: 25px;
    line-height: 25px;
    white-space: nowrap;
    background: #fafafa;
    border: 1px solid #e9e9e9;
    border-radius: 4px;
    padding: 0px 7px;
    display: inline-block;

  }
}
.select-big {
  display: flex;
  align-items: center;
  border-bottom: 1px solid #eee;
  padding-bottom: 30px;
  margin-bottom: 30px;
  .select-left {
    width: 150px;
    margin-right: 10px;
  }
  .select-right{
    flex: 1;
  }
}
.formBig {
  display: flex;
  flex-wrap: wrap;
  background: #ebf2ff;
  border-radius: 4px;
  padding: 12px;
  margin-bottom: 28px;
  .item-li {
    display: flex;
    align-items: center;
    margin-top: 12px;
    padding-right: 50px;
    color: rgba(0, 0, 0, .45);
    .content {
      color: rgba(0, 0, 0, .85);
    }
    &.row-li {
      width: 100%;
    }

  }
}
.btn-r {
  color: #3070ff;
  height: 25px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 4px 4px 4px 0;
  cursor: pointer;
}
</style>
